@extends('console.layout.frame')

@section('content')

    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">图文管理</h1>
    </div>
    <div class="wrapper-md">

        <div class="panel panel-default">
            <div class="panel-heading">
                图文素材列表
            </div>
            <div class="table-responsive">
                <table class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th>图片</th>
                        <th>标题</th>
                        <th style="width:100px;">作者</th>
                        <th>描述</th>
                        <th style="width:80px;">数量</th>
                        <th>更新时间</th>
                        <th style="width:150px;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($lists['item'] as $item)
                        @php
                            $content = $item['content']['news_item'][0];
                        @endphp
                        <tr>
                            <td><img src="{{ $content['thumb_url'] }}" style="max-height: 50px"></td>
                            <td>{{ $content['title'] }}</td>
                            <td>{{ $content['author'] }}</td>
                            <td>{{ $content['digest'] }}</td>
                            <td>{{ count($item['content']['news_item']) . ' 篇' }}</td>
                            <td>{{ date('Y-m-d H:i:s', $item['update_time']) }}</td>
                            <td>
                                <a target="_blank" href="{{ $content['url'] }}">
                                    <button class="btn btn-default">预览</button>
                                </a>
                                <a href="{{ url('console/material/news/edit/'.$item['media_id']) }}">
                                    <button class="btn btn-default">编辑</button>
                                </a>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <footer class="panel-footer">
                <?php
                $list_last_offset = $list_offset - $list_count;
                $list_next_offset = $list_offset + $list_count;
                if ($list_next_offset > $lists['total_count']) {
                    $list_next_offset = 0;
                }
                ?>
                <div class="row">
                    <div class="col-sm-4 hidden-xs">
                        @if($list_last_offset >= 0)
                            <a href="?offset={{ $list_last_offset }}" class="btn btn-default"><i
                                        class="fa fa-chevron-left"></i> 上一页</a>
                        @endif
                    </div>
                    <div class="col-sm-4 text-center">
                        <small class="text-muted inline m-t-sm m-b-sm">第 {{ $list_offset + 1 }}
                            至 {{ $list_offset + $lists['item_count'] }} 项，共 {{ $lists['total_count'] }} 项
                        </small>
                    </div>
                    <div class="col-sm-4 text-right text-center-xs">
                        @if($list_next_offset != 0)
                            <a href="?offset={{ $list_next_offset }}" class="btn btn-default">下一页 <i
                                        class="fa fa-chevron-right"></i></a>
                        @endif
                    </div>
                </div>
            </footer>
        </div>

    </div>

@endsection